<?php
//We start by displaying a form where the user can change his/her status
?>
<form action="<?php echo $this->baseURL() ?>/status/status/publish/"  method="post">
<textarea name="status"></textarea>
<button type="submit">Publish</button>
</form>

<?php
//we check if the user follow the other user
//Have to check before if the user is not displaying his/her own statuses
if($this->stream['isFollowing']) echo '<div class="follow">You already follow '.$this->stream['user']['pseudo'].'</div>';
elseif($this->userPseudo == $this->stream['user']['pseudo']) echo '<div class="follow">It\'s you</div>'; 
else{
	echo '<div class="follow"><a href="'.$this->baseURL().'/status/friendship/create/pseudo/'.$this->stream['user']['pseudo'].'/">Follow '.$this->stream['user']['pseudo'].'</a></div>';
}

//If no status we display a message
$statuses = $this->stream['data'];
if(empty($statuses)) {
	echo 'pas de status pour le moment';
	return;
}

?>
<ol class="statuses">
<?php

foreach($statuses as $mun=> $status) {

	$authorURL = $this->baseURL().'/status/index/user/pseudo/'.$status['user']['pseudo'].'/';
	?>

	<li class="status" id="status<?php echo $status['id'] ?>">
		<a href="<?php echo $authorURL ?>"><img src="<?php echo $this->avatarBaseURL.$status['user']['pseudo'].'.gif' ?>" class="avatarImage" alt="<?php echo $status['user']['pseudo'] ?>" width="44px" height="44px"  /></a>
		<div class="details">
			<span class="author"><a href="<?php echo $authorURL ?>"><?php echo $status['user']['pseudo'] ?></a></span>
			<span class="text"><?php echo $status['status'] ?></span>
			<span class="date">
			<a href="<?php echo $this->baseURL().'/status/status/display/id/'.$status['id'].'/' ?>">
			<?php 
				$timeMode = $this->dateFormatter($status['publishedTime']);
				switch ($timeMode['mode']) {
				case 'seconds':
					echo ($timeMode['gap'] == 0)?'right now':($timeMode['gap'] == 1)?'1 second ago':$timeMode['gap'].' seconds ago';
					break;
				case 'minutes':
					echo ($timeMode['gap'] == 1)?'1 minute ago':$timeMode['gap'].' minutes ago';
				break;
				case 'hours':
					echo ($timeMode['gap'] == 1)?'about 1 hour ago':'about '.$timeMode['gap'].' hours ago';
				break;
				case 'date':
					echo $timeMode['day'].'/'.$timeMode['month'].'/'.$timeMode['year'].' '.$timeMode['hours'].':'.$timeMode['minutes'];
				break;
			}

			?>
			</a>
			</span>
		</div>
		
	</li>
	<?php
} //end foreach status

?>
</ol>